# == Schema Information
#
# Table name: products
#
#  id                  :integer          not null, primary key
#  brand_id            :integer
#  title               :string
#  status              :integer          default("on")
#  uuid                :string
#  msrp                :decimal(10, 2)
#  price               :decimal(10, 2)
#  desc                :text
#  lock_version        :integer
#  created_at          :datetime         not null
#  updated_at          :datetime         not null
#  spec_id             :integer
#  product_sign_id     :integer
#  category_ids        :string           default([]), is an Array
#  summary             :string
#  product_type        :integer          default("finished")
#  sales               :integer          default(0)
#  parent_category_ids :string           default([]), is an Array
#  is_top              :boolean
#

class ProductSerializer < ActiveModel::Serializer
   attributes :id, :title, :msrp, :price

   attribute :main_img_url do
     main_image = object.main_product_image
     if main_image
       main_image.image_url(:thumb)
     else
       'default_product.png'
     end
   end

end
